package cn.tansanqinger.controller.account;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import cn.tansanqinger.service.announcement.IAnnouncementService;
import cn.tansanqinger.service.hymenu.IHyMenuServer;
import cn.tansanqinger.util.PageData;

@Controller
@RequestMapping("/account/user")
public class AccountSystemMessageController {

	@Autowired
	private IHyMenuServer hyMenuServer;
	@Autowired
	private IAnnouncementService aservice;
	
	@RequestMapping("/systemmessage")
	public ModelAndView list(ModelAndView mv, HttpServletRequest request) {
		mv = hyMenuServer.selectHyMenuAll(mv);
		mv.addObject("user", request.getSession().getAttribute("user"));
		mv.addObject("selectCount", aservice.selectAnnouncementCount(request));
		mv.addObject("count", aservice.announcementCount(request));
		mv.addObject("announcementList", aservice.selectAnnouncement(request));
		mv.setViewName("account/message5");
		return mv;
	}
	
	/**
	 * 删除数据
	 * @param request
	 * @return
	 */
	@RequestMapping("/delete5")
	@ResponseBody
	public PageData delete5(HttpServletRequest request) {
		return aservice.delete(request);
	}
	
	/**
	 * 查询单一信息
	 * @param request
	 * @param mv
	 * @return
	 */
	@RequestMapping("/edit5")
	public ModelAndView edit5(HttpServletRequest request, ModelAndView mv) {
		mv.addObject("announcement", aservice.selectAnnouncementOne(request));
		mv.setViewName("/account/edit5");
		return mv;
	}
}
